package com.dgut.app.controller;

import com.dgut.common.utils.ApiException;
import com.dgut.common.utils.R;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

/**
 * @author IT00ZYQ
 * @Date 2021/2/2 16:38
 **/
@RestController
public class ErrorController {

    /**
     * 发生错误时跳转的处理器
     * @param request
     * @return
     */
    @RequestMapping("/app/filter/error")
    public R error(HttpServletRequest request) {
        ApiException e = (ApiException) request.getAttribute("exception");
        return R.error().code(e.getCode()).message(e.getMessage());
    }

}
